package Year22_Month03.day01;


import java.util.Scanner;

public class Main3{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int a = sc.nextInt();
        String[] list = new String[a];
        for (int i = 0; i < list.length; i++) {
            list[i] = sc.next();
        }
        boolean leng = lengfun(list);
        boolean zidian = ziDian(list);
        if(leng == true && zidian == true){
            System.out.println("both");
        }else if(leng == false && zidian == false){
            System.out.println("none");
        }else{
            if(zidian == true){
                System.out.println("lexicographically");
            }
            if(leng == true){
                System.out.println("lengths");
            }
        }
    }
    public static boolean lengfun(String[] arr){
        if(arr.length == 1){
            return true;
        }
        boolean key = true;

        for (int i = 1; i < arr.length; i++) {
            if(arr[i].length() < arr[i - 1].length()){
                key = false;
            }
        }
        return key;
    }

    public static boolean ziDian(String[] arr){
        if(arr.length == 1){
            return true;
        }
        boolean key = true;
        for (int i = 1; i < arr.length; i++) {
            if(arr[i].charAt(0) < arr[i - 1].charAt(0)){
                key = false;
            }
        }
        return key;
    }
}